clear
set mem 500m
set more off

use "MERGED ADULT_PERSON.dta"

drop if age<18

drop if smkev==.

replace wtia=. if smkev==2
replace wtia_sa=. if smkev==2

keep wtia wtia_sa sex age_p racerpi2 hispan_i region smkev origin_i educ1

gen sex2=.
replace sex2=1 if sex==1 & smkev~=2
replace sex2=2 if sex==2 & smkev~=2
replace sex2=. if smkev==2
label variable sex2 "sex - without neversmokers"

label define sexll 1 "male" 2 "female"

label values sex2 sexll

gen region1=.
replace region1=1 if region==1 & smkev~=2
replace region1=2 if region==2 & smkev~=2
replace region1=3 if region==3 & smkev~=2
replace region1=4 if region==4 & smkev~=2
label variable region1 "region - without neversmokers"

label define regionll 1 "northeast" 2 "midwest" 3 "south" 4 "west"

label values region1 regionll

gen racerpi1=.
replace racerpi1=1 if racerpi2==1 & smkev~=2
replace racerpi1=2 if racerpi2~=1 & smkev~=2
label variable racerpi1 "race - without neversmokers"

label define racerpil 1 "white only" 2 "other"

label values racerpi1 racerpil

gen hispan1=.
replace hispan1=1 if origin_i==1 & smkev~=2
replace hispan1=2 if origin_i==2 & smkev~=2
label variable hispan1 "ethnicity - without neversmokers"

label define hispanl 1 "hispanic/latino" 2 "not hispanic/latino"

label values hispan1 hispanl

su wtia_sa if smkev~=2
global mean = r(mean)
replace wtia_sa=wtia_sa/$mean

gen agecats=.
replace agecats=1 if age_p>=18 & age_p<=25 & smkev~=2
replace agecats=2 if age_p>=26 & age_p<36 & smkev~=2
replace agecats=3 if age_p>=36 & age_p<46 & smkev~=2
replace agecats=4 if age_p>=46 & age_p<56 & smkev~=2
replace agecats=5 if age_p>=56 & age_p<66 & smkev~=2
replace agecats=6 if age_p>65 & smkev~=2
label var agecats "age - without neversmokers"

label define agecatsl 0 "under 18" 1 "18-24" 2 "25-34" 3 "35-44" 4 "45-54" 5 "55-64" 6 "65+"

label values agecats agecatsl

gen educ2=.
replace educ2=1 if educ1<13 & smkev~=2
replace educ2=2 if educ1==13 & smkev~=2
replace educ2=2 if educ1==14 & smkev~=2
replace educ2=3 if educ1==15 & smkev~=2
replace educ2=3 if educ1==16 & smkev~=2
replace educ2=4 if educ1==17 & smkev~=2
replace educ2=4 if educ1==18 & smkev~=2
replace educ2=5 if educ1>18 & smkev~=2
replace educ2=. if educ1>21 & smkev~=2
label variable educ2 "educ - without neversmokers"

label define educl 1 "less than high school" 2 "high school graduate" 3 "some college" 4 "college graduate" 5 "graduate degree"

label values educ2 educl

*** note: occupational/tech associate's degrees go with "some college", academic associate's degree goes with "college graduate"

tab sex2 [aw=wtia_sa]
tab agecats [aw=wtia_sa]
tab educ2 [aw=wtia_sa]
tab racerpi1 [aw=wtia_sa]
tab hispan1 [aw=wtia_sa]
tab region1 [aw=wtia_sa]


